package com.fallsvc.re.javasesets.reflectemunlambda.singleton;

class Singleton {
    /**
     * 私有化构造器
     */
    private Singleton() {
    }

    /**
     * 对外提供公共的访问方法
     */
    public static Singleton getInstance() {
        return UserSingletonHolder.INSTANCE;
    }

    /**
     * 写一个静态内部类，里面实例化外部类
     */
    private static class UserSingletonHolder {
        private static final Singleton INSTANCE = new Singleton();
    }
}
public class Main {
    public static void main(String[] args) {
        Singleton u1 = Singleton.getInstance();
        Singleton u2 = Singleton.getInstance();
        System.out.println("两个实例是否相同：" + (u1 == u2));
    }
}